home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
dirparse.zip
/
DIRPARSE.PAS
< prev
Wrap
Pascal/Delphi Source File
|
1991-10-22
|
3KB
|
98 lines
Program Dir_Parser; (* Hi, STIPE wanted something to do this *)
(* Took 5 minutes.... *)
(*$M 2048, 0, 0 *) (* 2K stack, Min Heap 0, Max Heap 0 *)
Uses Dos, Crt; (* Use DOS allows use of FINDFIRST and FINDNEXT *)
Var
Temp,
Lines,
Index: Byte;
Const
ColorArray: Array[0..5] of Byte = (11,9,15,13,14,10);
Procedure Chk_Pause;
Var
Ch: Char;
Const
Lines: Word = 1;
Begin
Inc(Lines);
If (Lines mod 18) = 0 then
Begin
Write('<<MORE>>');
Inc(Lines);
Ch:= ReadKey;
GotoXY(Wherex-9, Wherey);
Writeln;
End;
End;
Procedure Parse(Param: String); (* Pass Name of extension to routine *)
Var
Info: SearchRec; (* SearchRec - Info that DOS returns *)
Temp, (* Used for Speed - No need to re-evaluate *)
(* The LENGTH every time in the For Loop *)
Index,
Counter: Byte; (* Index in For Loop *)
Begin
Counter:=0;
FindFirst('*.'+Param, AnyFile, Info); (* Find First Matching FileName *)
If (DosError = 18) then (* Any at All? *)
Begin
Temp:= Length(Param); (* Nope, convert extension to Upper *)
For Index:=1 to Temp do (* Case so it looks nice *)
Param[Index]:= Upcase(Param[Index]);
Writeln(' No Files of type ',Param,' found.'+#10#13);
Chk_Pause;
End;
While (DosError = 0) do (* Keep chuggin' so long as ther are *)
Begin
Inc(Counter); (* Files to be printed *)
Write(Info.Name:15);
FindNext(Info);
If ((Counter mod 5) = 0) then
Begin
Writeln;
Chk_Pause;
End;
End;
If ((Counter mod 5) <> 0) then
Begin
Writeln;
Chk_Pause;
End;
If (Counter > 0) then
Begin
Writeln(' Files of this type: ',Counter,+#10#13);
Chk_Pause;
End;
End;
Begin
If (ParamCount >= 1) Then (* Check to see if any command line params *)
Begin (* Were Specified. If not, give help *)
TextBackGround(Blue);
ClrScr;
Temp:= ParamCount;
For Index:=1 to Temp do (* If So, print all files w/given Extension *)
Begin
TextColor(ColorArray[Index mod 6]);
Parse(ParamStr(Index));
End
End
Else
Begin
TextBackGround(Blue);
TextColor(Yellow);
ClrScr;
Writeln('Dir-Parse: (c) 1991 GHT, Ltd.'+#10#13+
'USAGE: DIRPARSE <EXT> <EXT> <EXT>'+#10#13+
'Where <EXT> is an extension of the Filename you want'+#10#13+
'Handy to have .BAT file with commonly used extensions.');
End;
End.